<?php
declare (strict_types = 1);

namespace app\api\model\v1;

use think\Model;

/**
 * @mixin \think\Model
 * //整改表
 */
class Rectification extends AppModel
{
    //操作类型(1未整改，2，已整改，3延期，4，交办，5退回)
    const IS_TYPE_ZERO = 0;
    const IS_TYPE_ONE = 1;
    const IS_TYPE_TWO = 2;
    const IS_TYPE_THREE = 3;
    const IS_TYPE_FORE = 4;
    const IS_TYPE_FIVE = 5;
    const IS_TYPE_SIX = 6;
    const IS_TYPE_SEVEN = 7;

    //类型常量
    public static $is_type =array(
        self::IS_TYPE_ZERO => '全部',
        self::IS_TYPE_ONE => '未整改',
        self::IS_TYPE_TWO => '已整改',
        self::IS_TYPE_THREE => '延期中',
        self::IS_TYPE_FORE => '交办',
        self::IS_TYPE_FIVE => '退回中', //当前是到各级单位管理手中
        self::IS_TYPE_SIX => '退回', //此处的退回是指到达最后的管理员手中
        self::IS_TYPE_SEVEN => '销案' //此处的退回是指到达最后的管理员手中
    );

    const IS_STATUS_ZERO = 0;
    const IS_STATUS_ONE = 1;
    const IS_STATUS_TWO = 2;
    const IS_STATUS_THREE =3;

    //案件当前状态
    public static $is_status = array(
        self::IS_STATUS_ZERO => '全部',
        self::IS_STATUS_ONE => '待审核',
        self::IS_STATUS_TWO => '有效整改',
        self::IS_STATUS_THREE => '无效整改'
    );

    //关联关系
    public function collect(){
        return $this->belongsTo(Collect::class,'collect_id');
    }

    public function admin(){
        return $this->belongsTo(Admins::class,'admin_id')->field('id,username');
    }

    public function unit(){
        return $this->belongsTo(GatherCompany::class,'unit_id')->field('id,gather_company_title');
    }

    public function project(){
        return $this->belongsTo(Project::class,'project_id')->field('id,project_title');
    }
}
